import java.lang.reflect.Array;
import java.util.Arrays;

public class note6 {
  /*  public static void print(int[] array){
        int t=array.length;
        for(int i=0;i<t;i++){
            System.out.print(array[i]+" ");
        }
    }
    public static void test1(int[] arr){
        arr[0]=99;
    }
    public static void test2(int[] arr2){
        arr2=new int[]{100,200,300,400,500};
    }
    public static void test3(int[] arr3){
        arr3=new int[5];
        arr3[2]=888;
    }
    public static void main2(String[] args) {
        int[] array=new int[]{1,2,3,4,5};
        //print(array);
        //test1(array);
        //print(array);
        //System.out.println();
        //System.out.println("==================");
        //test2(array);
       // print(array);
        test3(array);
        print(array);
    }















    public static void main1(String[] args) {
        int a=10;
        int[] arr=new int []{1,2,3,4,5,6,7,89};
        int len=arr.length;
        System.out.println(len);
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.println();
        System.out.println("for-each循环");
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
        System.out.println("============================");
        //tostring函数解决
        String x= Arrays.toString(arr);
        System.out.println(x);
        //System.out.println(a);
    }


    public static void main3(String[] args) {
        int[] array=fuc();
        String s = Arrays.toString(array);
        System.out.println(s);
    }
    public static int[] fuc(){
        int a=1;
        int b=2;
        int[] ret=new int[]{a,b};
        return ret;
    }
*/



//自定义函数实现tostring---数组转字符串
    public static void main(String[] args) {
        int[] arr=new int[]{1,2,3,45};
        String ret=tostring(arr);
        System.out.println(ret);
    }
    public static String tostring(int[] arr){
        String s="[";
        for(int i=0;i<arr.length;i++){
            s+=arr[i];
            if(i!=arr.length-1){
                s+=",";
            }
        }
        s+="]";
        return s;
    }
}
